class Solution:
	# @param {integer[]} nums
	# @return {integer}
	def maxProduct(self, nums):
		m = [None for i in nums]
		n = [None for i in nums]
		ans = m[0] = n[0] = nums[0]
		for i in xrange(1,len(nums)):
			m[i] = max(m[i-1]*nums[i], n[i-1]*nums[i], nums[i])
			n[i] = min(m[i-1]*nums[i], n[i-1]*nums[i], nums[i])
			ans = max(m[i], n[i], ans)
		#print n,m
		return ans

if __name__ == '__main__':
	a = [-2,3,-4]
	so = Solution()
	print so.maxProduct(a)